@ECHO OFF

REM -------------------------------------------------------------

REM Copyright (c) 2012, Silicon Laboratories, Inc.

REM Filename : USB_BL_Build.txt
REM Project  : USB Bootloader (USB_BL)
REM Created  : 12 APR 2006 / PKC
REM Devices  : C8051F320/1/6/7/'F34x/'F38x
REM Toolchain: Keil

REM Description:
REM This is a batch file that accepts a parameter. 
REM To prevent accidental execution, this has been renamed to *.txt
REM See other batch files in this folder (*.bat) on how to call this file correctly

REM -------------------------------------------------------------

ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO ------------------------------------------------------------
ECHO.
ECHO.USB Bootloader Version 2.12 - Beginning Build...
ECHO Device type: %1
ECHO.


if "%1"=="_C8051F320_1_" GOTO STARTBUILD
if "%1"=="_C8051F326_7_" GOTO STARTBUILD
if "%1"=="_C8051F34X_32K_" GOTO STARTBUILD
if "%1"=="_C8051F34X_64K_" GOTO STARTBUILD
if "%1"=="_C8051F38X_32K_" GOTO STARTBUILD
if "%1"=="_C8051F38X_64K_" GOTO STARTBUILD

ECHO.Invalid microcontroller choice. See USB_BL_Build_F320_1.bat for an example call.
GOTO QUITBUILD

:STARTBUILD

C:\Keil\C51\BIN\c51.exe USB_BL_ISR.c DB OE OT(9,Size) DEFINE(%1)
C:\Keil\C51\BIN\c51.exe USB_BL_Main.c DB OE OT(9,Size) DEFINE(%1)
C:\Keil\C51\BIN\c51.exe USB_BL_QueueMgmt.c DB OE OT(9,Size) DEFINE(%1)
C:\Keil\C51\BIN\c51.exe USB_BL_USB_Descriptor.c DB OE OT(9,Size) DEFINE(%1)
C:\Keil\C51\BIN\A51.EXE USB_BL_STARTUP.A51 XR GEN DB EP DEFINE(%1)

if "%1"=="_C8051F320_1_" GOTO F320_16K_LINK
if "%1"=="_C8051F326_7_" GOTO F326_16K_LINK
if "%1"=="_C8051F34X_32K_" GOTO F34X_32K_LINK
if "%1"=="_C8051F34X_64K_" GOTO F34X_64K_LINK
if "%1"=="_C8051F38X_32K_" GOTO F38X_32K_LINK
if "%1"=="_C8051F38X_64K_" GOTO F38X_64K_LINK

:F320_16K_LINK
if "%2%" == "FREE_MODE" GOTO F320_16K_LINK_FREE
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F320_16K_LINK.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F320_1_16K.OMF
GOTO QUITBUILD
:F320_16K_LINK_FREE
ECHO 
ECHO 
ECHO Link object in free way ...
ECHO 
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F320_16K_LINK_FREE_MODE.TXT 
C:\Keil\C51\BIN\OH51.EXE USB_BL_F320_1_16K.OMF
GOTO QUITBUILD


:F326_16K_LINK
if "%2%" == "FREE_MODE" GOTO F326_16K_LINK_FREE
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F326_16K_LINK.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F326_7_16K.OMF
GOTO QUITBUILD
:F326_16K_LINK_FREE
ECHO 
ECHO 
ECHO Link object in free way ...
ECHO 
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F326_16K_LINK_FREE_MODE.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F326_7_16K.OMF
GOTO QUITBUILD


:F34X_32K_LINK
if "%2%" == "FREE_MODE" GOTO F34X_32K_LINK_FREE
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F34X_32K_LINK.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F34X_32K.OMF
GOTO QUITBUILD
:F34X_32K_LINK_FREE
ECHO 
ECHO 
ECHO Link object in free way ...
ECHO 
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F34X_32K_LINK_FREE_MODE.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F34X_32K.OMF
GOTO QUITBUILD



:F34X_64K_LINK
if "%2%" == "FREE_MODE" GOTO F34X_64K_LINK_FREE
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F34X_64K_LINK.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F34X_64K.OMF
GOTO QUITBUILD
:F34X_64K_LINK_FREE
ECHO 
ECHO 
ECHO Link object in free way ...
ECHO 
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F34X_64K_LINK_FREE_MODE.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F34X_64K.OMF
GOTO QUITBUILD


:F38X_32K_LINK
if "%2%" == "FREE_MODE" GOTO F38X_32K_LINK_FREE
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F38X_32K_LINK.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F38X_32K.OMF
GOTO QUITBUILD
:F38X_32K_LINK_FREE
ECHO 
ECHO 
ECHO Link object in free way ...
ECHO 
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F38X_32K_LINK_FREE_MODE.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F38X_32K.OMF
GOTO QUITBUILD


:F38X_64K_LINK
if "%2%" == "FREE_MODE" GOTO F38X_64K_LINK_FREE
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F38X_64K_LINK.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F38X_64K.OMF
GOTO QUITBUILD
:F38X_64K_LINK_FREE
ECHO 
ECHO 
ECHO Link object in free way ...
ECHO 
C:\Keil\C51\BIN\BL51.EXE @.\LINK_CMD\F38X_64K_LINK_FREE_MODE.TXT
C:\Keil\C51\BIN\OH51.EXE USB_BL_F38X_64K.OMF
GOTO QUITBUILD


:QUITBUILD
ECHO.
ECHO.End of build process.